<?php

	include_once '../controladores/ControladorUsuarios.php';
	include_once '../clases/user.php';
	include_once '../config.inc.php';
						
	 if ($_POST['submit'] == "cancel")
		header("Location:login.html");
	else
	{
	    $command = new ControladorUsuarios();
		
		if (!$command->isExistingUser($_POST['last_name'])){
			
			mkdir(ROUTE_APPLICATIONS_USERS.$_POST['last_name']);
								
			mkdir(ROUTE_APPLICATIONS_USERS.$_POST['last_name']."/Applications");

			$command->userCreate(new User($_POST['first_name'],$_POST['last_name'],$_POST['password']));
		
			header("Location:user_index.php?user_id=".$command->obtainUserId($_POST['last_name']));
			
		}
		
		
	}
?>